package com.demo.gateway.app.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模拟feign的Api功能，网关可以访问到接口来获取限流的配置等信息
 * {@link com.demo.gateway.sentinel.api.ConfigClient}
 */
@Slf4j
@RefreshScope
@RestController
@RequestMapping("/config")
public class ConfigController {

    /**
     * 通过动态刷新的nacos配置模拟配置项的变化
     */
    @Value("${fw.limit:false}")
    private boolean fwLimit;
    /**
     * 获取限流配置
     * @return
     */
    @GetMapping("")
    public boolean config(){
        log.info("有人来查询限流配置了");
        return fwLimit;
    }
}
